<?php
/*
 *      abcaptcha.class.php
 *      
 *      Copyright 2009 Alberto Berroteran <ashrey10@yahoo.es>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
class ABCaptcha{
	private $s_asker = '';
	private $s_aswer = '';
	function __construct(){
		$var = $this->randAsker();
		$this->s_asker = $var[0];
		$this->s_aswer = $var[1];       
	}
	
	function getAsker(){
		return $this->s_asker;
	}
	
	function getAswer(){
		return $this->s_aswer;
	}
	
	private function randAsker(){
	$var1 = rand(0, 9);
	$var2 = rand(0, 9);
	$var3 = rand(9, 15);
	$a = array(array('¿En que año estamos?', date('Y')),
	 			array('¿Cuanto ojos tiene un perro?', 2),
	 			array('¿Cuantos meses tiene el año?', 12),
	 			array('¿Cuantos dia tiene enero?', 31),
	 			array('¿Cuantas horas tiene el dia?', 24),
	 			array('¿Cual es la edad mínima para votar?', 18),
	 			array('Suma '. $var1. ' mas '.$var2, $var1 + $var2),
	 			array('Si sumas '. $var1. ' mas '.$var2. ' ¿Cuanto es?', $var1 + $var2),
	 			array('¿Cuanto es '. $var1. ' + '.$var2 . '?', $var1 + $var2),
	 			array('Multiplica '. $var1 . ' por '. $var2, $var1 * $var2),
	 			array('Restale '. $var1 . ' a '. $var3, $var3-$var1),
	 			array('¿Cuanto es '. $var3 . ' menos '. $var1 . '?', $var3 -$var1),
	 			);
	 	return $a[rand(0, count($a) -1)];
	}
	
}
